<layout name="site" />
	 <div id="mask"></div>
	 <div id="prompt">
	 <p></p>
    <span class="close"></span>
	 	<div class='ptel-box'><a href="" class="ptel">拨打电话</a></div>
	 </div>
     <div class="contlist" id="contlist">
    <ul id="list"></ul>
  </div>
  <input type="hidden" id="add-num" value="2"/>

  <script>
   var cid = "{$sid}"*1;
   var cat_id = "{$cat_id}"*1;
   var url="{:U('Product/getProductInfo')}";
   function oWidth(){
     $( '#contlist img' ).each(function(i){
  	   $( '#contlist img' ).eq(i).height($( '#contlist img' ).eq(i).width());
     })
   }
   $( '#prompt .close' ).click(function(){
      $( '#mask' ).hide();
      $( '#prompt' ).hide();  
   })
   fz();
   function fz(){
     $( '#prompt' ).css(
       'marginTop',($(window).height()-$( '#prompt' ).height())/2
     );
   };
  function oAjax() {
      $( '#contlist li' ).each(function(i){
       		 $( '#contlist li' ).eq(i).click(function(){
	       		 $( '#mask' ).show().css({'opacity':'.2'});
	             $( '#prompt' ).show(); 
		   		 $( '#prompt p' ).html( $(this).get(0).description );
		 		 $( '#prompt .ptel' ).attr({href: 'tel:'+$(this).get(0).tel} );
		 		 fz();
       		 })
       });
   }
   var ourl="{:U('Article/more')}";
   var oList=document.getElementById('list');
   $.ajax({
   	   type:'POST',
   	   url:ourl,
   	   data:{id:cat_id, sid: cid},
   	   success:function(data){
   		   var data = data.extra;
   		   for(var i = 0 ; i < data.length ; i++){
   		     var oDiv=document.createElement("li");
     		   oDiv.innerHTML="<span>" +  data[i].cid + "</span><img src='" + data[i].thumb + "'>";
     		   oDiv.description = data[i].description;
     		   oDiv.tel = data[i].tel;
     		   oList.appendChild(oDiv);
   		   }
   		   oWidth();
   		   oAjax();
   	   }  
   })
   var oPass=true;
   window.onscroll=function(){
     if(($(document.body).height()-$(window).scrollTop()-$(window).height())<10){
        if( oPass == true ){
              $.ajax({
               type:'POST',
               url:ourl,
               data:{id:cat_id, sid: cid, p:$( '#add-num' ).val()},
               success:function(data){
               var data = data.extra;
                 if(data!=null||data!=undefined){
                   for(var i = 0 ; i < data.length ; i++){
                     $('#add-num').val(Number($('#add-num').val())+1);//加载次数
                     var oDiv=document.createElement("li");
                     oDiv.innerHTML="<span>" + data[i].cid + "</span><img src='" + data[i].icon + "'><input type='hidden' value='"+  data[i].url +"' >";
                     oList.appendChild(oDiv);
                   }
                   oWidth();
                   oAjax();
                 }else{
                   GH.showMessage('已经没有数据了哦~');
                 }
               }  
              })
       }
     }
     if(($(document.body).height()-$(window).scrollTop()-$(window).height())>10){
         oPass=true;
     }
   }
</script>